#ifndef _MYSQL_INFO_
#define _MYSQL_INFO_
#include <my_header.h>
#include <mysql/mysql.h>
typedef struct user_info_s{
    int id;
    char user_name[50];
    char salt[100];
    char encrypted_password[300];
    int is_deleted;
}user_info_t;
typedef struct v_dir_s{
    int id;
    char file_name[300];
    char user_name[50];
    int parent_id;
    char type[10];
    char path[300];
    int is_deleted;
    char sha_sum[300];
}v_dir_t;
typedef struct log_s{
    int id;
    int user_id;
    char op_time[100];
    char op[100];
    int status;
    char msg[300];
}log_t;
//获取一个mysql连接
MYSQL* get_one_mysql_connect();

int log_info(MYSQL*mysql,int user_id,const char *op,int status,const char *msg);

int is_exist_username(MYSQL*mysql,char *user_name);

int get_user_by_id(MYSQL* mysql,user_info_t * user,int user_id);

int is_user_exist(MYSQL*mysql,int user_id);

int add_one_user(MYSQL*mysql,user_info_t *user);

int valid_user(MYSQL*mysql,user_info_t *user);

int get_user_id_by_user_name(MYSQL*mysql,char * user_name);

int get_user_name_by_id(MYSQL*mysql,char *user_name,int id);

void close_mysql_connect(MYSQL*mysql);

void print_user(user_info_t *user);

int get_last_login_time(MYSQL*mysql,char *last_login_time,int user_id);

int recent_use_cmd(MYSQL*mysql,char *recent_use_cmd,int user_id);

//0表示成功查询到,-1表示未找到匹配user_name
int get_user_name_by_vid(MYSQL*mysql,int id,char *user_name);

#endif
